﻿namespace Hotel.Module.Resources.Models
{
    using System;   
    using Entities = Hotel.Module.Resources.DataRepository;

    public class Service : Model.Infrastructure.IDistributedStorageEntity
    {
        /// <summary>
        /// Creates a new Instance of Service according to recived Entity Service instance
        /// </summary>
        /// <param name="entity">Entity Service object from which new Service instance will be created</param>
        public static Service FromEnityModel(Entities.Service entity)
        {
            Service result = new Service();
            if (entity == null)
            {
                return null;
            }
            else
            {
                result.Cost = entity.Cost;
                result.ID = entity.Id;
                result.Name = entity.Name;
                result.OrderID = entity.OrderID;                
                result.Rated = entity.Rated;
            }
            return result;
        }
        /// <summary>
        /// Name of the service
        /// </summary>
        public string Name { get; set; }  

        /// <summary>
        /// Cost of the current service
        /// </summary>
        public double Cost { get; set; }

        public string PartitionKey { get; set; }

        public string RowKey { get; set; }

        public DateTime Timestamp { get; set; }

        /// <summary>
        /// The idetnitification number of service
        /// </summary>
        public int ID { get; set; }

        /// <summary>
        /// Identificational number of order to wich this service have to be included
        /// </summary>
        public int OrderID { get; set; }

        /// <summary>
        /// If service belong to rated
        /// </summary>
        public bool Rated { get; set; }


        /// <summary>
        /// Assignes to recieved object data from current instnce
        /// </summary>
        /// <param name="obj">Object to which the data of current insctnce will be copied</param>
        public void AssignTo(object obj)
        {
            if (obj is Entities.Service)
            {
                Entities.Service result = obj as Entities.Service;

                result.Cost = Cost;
                result.Id = ID;
                result.Name = Name;
                result.OrderID = OrderID;
                result.Rated = Rated;
                return;
            }

            throw new NotSupportedException();
        }
    }
}
